package com.iecm.udp.initializer;

import com.iecm.udp.handler.UdpServerHandler;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * udp服务初始类
 */
@Component
public class UdpServerInitializer extends ChannelInitializer<Channel> {

	@Autowired
    private UdpServerHandler udpServerHandler;

	@Override
	protected void initChannel(Channel channel) throws Exception {
		ChannelPipeline pipeline = channel.pipeline();
		//自定义Handler
		pipeline.addLast("udpServerHandler", udpServerHandler);
	}
}